package cate.game.play.skill.active;

import cate.common.table.d.GD;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.effect.SkillEffect;

/**
 * 发动技能与随机1名敌方英雄交换生命值比例，优先选择处于【黄泉梦境】的英雄，若目标最大生命值大于孟婆2倍，则发动失败，
 */
public class 孟婆换血AH extends ActiveHandler{

	private double 生命倍数;

	//生命倍数=2
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		生命倍数 = args.getDouble("生命倍数", 2d);
	}

	@Override
	public void afterSingleEffect(SkillActionCtx action, SkillEffect effect, Fighter target) {
		double hpMaxA = skill.owner.attr.total().hpTotal();
		double hpMaxB = target.attr.total().hpTotal();
		if (hpMaxA * 生命倍数 < hpMaxB) {
			return;
		}
		int rateA = skill.owner.attr.total().hpCurRate();
		int rateB = target.attr.total().hpCurRate();
		double hpA = hpMaxA * rateB / GD.W_10000_0;
		double hpB = hpMaxB * rateA / GD.W_10000_0;
		skill.owner.attr.hpCur(hpA,action);
		target.attr.hpCur(hpB, action);
	}
}
